{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">标题：</label>
                            <div class="layui-input-block">
                                <input type="text" name="new_title" value="{$info.new_title}" lay-verify="required" placeholder="标题" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">缩略图：</label>
                            <input type="hidden" name="new_thumb" id="lay-img" lay-verify="image" value="{$info.new_thumb}">
                            <div class="layui-input-block">
                                <div id="lay-upload">上传图片</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览图：
                                    <div class="layui-upload-list" id="lay-list">
                                        <img class="layui-append-img" src="{$info.new_thumb}" onerror="this.src='/static/admin/images/no_img.jpg'">
                                    </div>
                                </blockquote>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">标签：</label>
                            <div class="layui-input-block">
                                <input type="text" name="new_sign_left" value="{$info.new_sign_left}" lay-verify="required" placeholder="标签" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">话题：</label>
                            <div class="layui-input-block">
                                <input type="text" name="new_sign_right" value="{$info.new_sign_right}" lay-verify="required" placeholder="话题" class="layui-input ">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group" id="new_fid">
                            <label class="layui-form-label">类型：</label>
                            <div class="layui-input-block">
                                <select name="new_fid" lay-filter="rolefid">
                                    <option value="1" {$info.new_fid==1 ? 'selected' : ''}>足球</option>
                                    <option value="2" {$info.new_fid==2 ? 'selected' : ''}>篮球</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 {$info.new_fid==2 ? 'hidden' : ''}" id="new_type1">
                            <label class="layui-form-label">选择分类：</label>
                            <div class="layui-input-block">
                                <select name="new_type1"  lay-search="">
                                    <option value="" >请选择</option>
                                    {foreach name="types1" item="v"}
                                    <option value="{$v.nt_id}" {if $info.new_type==$v.nt_id}selected{/if}>{$v.nt_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8  {$info.new_fid==1 ? 'hidden' : ''}" id="new_type2">
                            <label class="layui-form-label">选择分类：</label>
                            <div class="layui-input-block">
                                <select name="new_type2"  lay-search="">
                                    <option value="" >请选择</option>
                                    {foreach name="types2" item="v"}
                                    <option value="{$v.nt_id}" {if $info.new_type==$v.nt_id}selected{/if}>{$v.nt_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">内容类型：</label>
                            <div class="layui-input-block">
                                <select name="new_video" lay-filter="role">
                                    <option value="1" {$info.new_video==1 ? 'selected' : ''}>图文</option>
                                    <option value="2" {$info.new_video==2 ? 'selected' : ''}>视频</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10 {$info.new_video==2 ? 'hidden' : ''}" id="new_content">
                            <label class="layui-form-label">内容：</label>
                            <div class="layui-input-block" id="LAY_editor" lay-verify="editor">
                                <p>{$info.new_video==1 ? $info.new_content : ''}</p>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 {$info.new_video==2 ? '' : 'hidden'}" id="video">
                            <label class="layui-form-label">视频：</label>
                            <input type="hidden" name="video" id="lay-img2" lay-verify="image" value="{$info.new_video==2 ? $info.new_content : ''}">
                            <div class="layui-input-block">
                                <div id="lay-upload2">上传视频</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览：
                                    {if $info.new_video==2}
                                    <div class="layui-upload-list" id="lay-list2">
                                        <video class="layui-append-img" src="{$info.new_video==2 ? $info.new_content : ''}" controls="controls"></video>
                                    </div>
                                    {/if}
                                </blockquote>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">是否上架：</label>
                            <div class="layui-input-block">
                                <select name="new_status" >
                                    <option value="1" {$info.new_status==1 ? 'selected' : ''}>上架</option>
                                    <option value="2" {$info.new_status==2 ? 'selected' : ''}>下架</option>
                                </select>
                            </div>
                        </div>
                        <input type="hidden" value="{$info.new_id}" name="new_id">
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    var editor = wk.wang({elem:'#LAY_editor'});
    wk.uploadImg({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});
    wk.uploadImg({size:500,num:2,type:'MP4,Mp4,mP4,mp4',url:"{:url('Upload/upload')}",video:3}); //视频
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
//        form.verify({
//            editor:function(value,item){
//                if(editor.txt.html() == '<p><br></p>'){
//                    return '请填写内容';
//                }
//            }
//        });
        form.on('submit(component-form-element)', function (data) {
            data.field.new_content = editor.txt.html();
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('newEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        })
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
        form.on('select(role)', function(data){
            if(data.value == 1){
                $('#new_content').removeClass('hidden');
                $('#video').addClass('hidden');
            }else{
                $('#new_content').addClass('hidden');
                $('#video').removeClass('hidden');
                wk.uploadImg({size:500,num:2,type:'MP4,Mp4,mP4,mp4',url:"{:url('Upload/upload')}",video:3}); //视频
            }
        });
        form.on('select(rolefid)', function(data){
            if(data.value == 1){
                $('#new_type1').removeClass('hidden');
                $('#new_type2').addClass('hidden');
            }else{
                $('#new_type1').addClass('hidden');
                $('#new_type2').removeClass('hidden');
            }
        });
    });
</script>

</body>
</html>
